import { addCsvData } from "../csv";
import { touchEventData } from "./event";

export enum MapAction {
    Click = 'Click', // 点击事件
    Input = 'Input', // 输入事件
    Zoom = 'Zoom', // 缩放事件
    Swipe = 'Swipe', // 滑动事件
    Auto = 'Auto' // 自动事件 (通过特殊指令，自动触发的一系列事件)
}

// 地图Widget
export enum MapWidget {
    SearchInput = 'SearchInput', // 搜索输入框
    SearchHistoryItem = 'HistoryItem', // 搜索历史列表项
    SearchSuggestionItem = 'SearchSuggestionItem', // 搜索建议列表项
    StartNavigation = 'StartNavigation', // 开始导航按钮
    CloseNavigation = 'CloseNavigation', // 关闭导航
    RecommendRouteItem = 'RecommendRouteItem', // 选择导航路由
    Map = 'Map', // 地图
}

// 地图事件
function eventMap(action: MapAction.Click, widget: MapWidget.SearchInput, eventKey: `${MapWidget.SearchInput}_focus`, widgetId: MapWidget.SearchInput): void;
function eventMap(action: MapAction.Click, widget: MapWidget.SearchHistoryItem, eventKey: `${MapWidget.SearchHistoryItem}${number}`, widgetId: `${MapWidget.SearchHistoryItem}${number}`, value: string): void;
function eventMap(action: MapAction.Click, widget: MapWidget.SearchSuggestionItem, eventKey: `${MapWidget.SearchSuggestionItem}${number}`, widgetId: `${MapWidget.SearchSuggestionItem}${number}`, value: string): void;
function eventMap(action: MapAction.Click, widget: MapWidget.RecommendRouteItem, eventKey: `${MapWidget.RecommendRouteItem}${number}`, widgetId: `${MapWidget.RecommendRouteItem}${number}`, value: string): void;
function eventMap(action: MapAction.Click, widget: MapWidget.CloseNavigation, eventKey: MapWidget.CloseNavigation, widgetId: MapWidget.CloseNavigation): void;
function eventMap(action: MapAction.Click, widget: MapWidget.StartNavigation, eventKey: MapWidget.StartNavigation, widgetId: MapWidget.StartNavigation): void;




function eventMap(action: MapAction.Input, widget: MapWidget.SearchInput, eventKey: `${MapWidget.SearchInput}_input`, widgetId: MapWidget.SearchInput, value: string): void;

function eventMap(action: MapAction.Zoom, widget: MapWidget.Map, eventKey: `${MapWidget.Map}_zoom`, widgetId: MapWidget.Map, value: touchEventData): void;

function eventMap(action: MapAction.Swipe, widget: MapWidget.Map, eventKey: `${MapWidget.Map}_swipe`, widgetId: MapWidget.Map, value: touchEventData): void;

function eventMap(action: MapAction.Auto, widget: null, eventKey: `Navagation`, widgetId: null, value: string): void;
function eventMap(action: MapAction.Auto, widget: null, eventKey: MapWidget.CloseNavigation, widgetId: null): void;

function eventMap(action: MapAction, widget: MapWidget | null, eventKey: any, widgetId: any, value?: any): void {
    const data = { app: "Map", event_key: eventKey, data_json: { action, widget_type: widget, widget_id: widgetId, value } };
    addCsvData(data);
}
export { eventMap } 